from constants.recognition import RecognitionStrategy, TimeStrategy
from recognition import Recognition


class HighWalk(Recognition):
    def __init__(self):
        super().__init__()
        self.time_strategy = [TimeStrategy.TRADING.value]
        self.type = RecognitionStrategy.HIGH_WALK.value

    def recognize(self,data):
        lastPrice=data.get("tick").get("lastPrice")
        open=data.get("tick").get("open")
        low=data.get("tick").get("low")
        lastClose=data.get("tick").get("lastClose")
        try:
            openChg = round((open - lastClose) / lastClose * 100, 2)
            lastChg = round((lastPrice - low) / low * 100, 2)
            if openChg <=-3 and lastChg >= 5 and lastPrice > open:
                self.reminder(data)
                return True
            elif openChg >= -3 and lastChg>=3 :
                self.reminder(data)
                return True
        except:
            return False

        return False

    # def regression(self, data):
    #     quote = data.get('quote')
    #     open_price = quote.get('open')
    #     newest = quote.get('newest')

    #     if newest < open_price:
    #         return True
    #     return False